﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.huawei.esdk.tp.professional.eSDKTPProfessionalOrgaMgr;
using com.huawei.esdk.tp.professional.DataType;
using System.Web.Services.Protocols;
using com.huawei.esdk.tp.professional.Utils;

namespace com.huawei.esdk.tp.professional.local
{
    public partial class OrgaMgrServiceEx
    {
        private static string url = com.huawei.esdk.tp.professional.Utils.UtilsSettings.URL + com.huawei.esdk.tp.professional.Utils.UtilsSettings.tpProfessionalOrgaMgr;
        private static TPProfessionalOrgaMgrService OrgaMgr = new TPProfessionalOrgaMgrService(url);

        private static OrgaMgrServiceEx instance = null;
        protected OrgaMgrServiceEx()
        {

        }

        public static OrgaMgrServiceEx Instance()
        {
            if (null == instance)
            {
                instance = new OrgaMgrServiceEx();
            }
            return instance;
        }

        public TPSDKResponseEx<OrganizationItemEx[]> queryOrganizationEx()
        {
            OrgaMgr.CookieContainer = AuthorizeServiceEx.cookieJar;
            TPSDKResponseEx<OrganizationItemEx[]> result = new TPSDKResponseEx<OrganizationItemEx[]>();
            try
            {
                OrganizationItemEx[] orgs;
                result.resultCode = OrgaMgr.queryOrganizationEx(out orgs);
                if (result.resultCode == 0)
                {
                    result.result = orgs;
                }
                return result;
            }
            catch (SoapHeaderException e)
            {
                int errorCode = ExceptionUtils.processSoapException(e);
                result.resultCode = errorCode;
                return result;
            }
        }
    }
}
